<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
		<link rel="stylesheet" href="static/css/bootstrap.min.css" />
		<link rel = "stylesheet" href = "static/css/globle.css"/>
		<script type="text/javascript" src = "static/js/jquery.js"></script>
	<title></title>
</head>
<body>
 <div class="navbar navbar-fixed-top" id = "manager">
			<div class="navbar-inner">
				<div class="container">
					<a  class = "brand" href="#">项目管理系统</a>
			
				</div>
			</div>
</div>
	<div class="container" style = "margin-top:60px">
		<div class="row" style = "margin-top:10px">
			<div class="span3">
				<div style="padding: 8px 0;" class="well">
					<ul class="nav nav-list">
					  <li class="nav-header">${project.p_name }</li>
					  <li ><a href="project.jspx?_m=project&pid=${project.p_id }"><i class="icon-home"></i>最新动态</a></li>
					  <li><a href="goal.jspx?p_id=${project.p_id }"><i class="icon-flag"></i>目标</a></li>
					  <li><a href="material.jspx?pid=${project.p_id }"><i class="icon-folder-open"></i>资料库</a></li>
					  <li><a href ="fileShare.jspx?pid=${project.p_id }"><i class="icon-file"></i>文件共享</a></li>
					  <li><a href="contact.jspx?pid=${project.p_id }"><i class="icon-user"></i>联系人</a></li>
					  <li class="active"><a href="idear.jspx?pid=${project.p_id }"><i class="icon-fire icon-white "></i>想法</a></li>
					  <li><a href="#"><i class="icon-warning-sign"></i>Bug</a></li>
					  <li><a href="#"><i class="icon-cog"></i>项目设置</a></li>
					</ul>
				</div>
			</div>
			
				<div class = "span9">
				    
				
				<ul class="breadcrumb" style = "margin-top:40px;margin-bottom:0px;border-radius:3px 3px 0 0;">
						<li class = "active "> <i class="icon-folder-open"></i>想法>${idear.i_title }</li>
				</ul>
					<div class = "well" style = "border-radius:0 0 3px 3px;background-color:white">
					
						<div class = "pager-header">
							<h2 style = "text-align:left">${idear.i_title}<small>【${idear.member}】发布于</small></h2>
						</div>
							<p>${idear.i_content}</p>
						
				
					</div>
					<div class="page-header">
						<h2>评论</h2>
					</div>
					<!--
					<form action = "idear.jspx?_m=comment?iid=${idear.i_id }">-->
						<input type = "hidden" id = "iid" value = "${idear.i_id }"/>
						<textarea rows="5" style = "width:400px" name = "content" id = "dec"></textarea></br>
						<input type = "button" value = "发表" class = "btn" id = "btn"/>
						</br>
						</br>
					<c:forEach items = "${comment}" var = "c">
						<blockquote>
							<h4>${c.comment_content}</h4>
							<small>${c.member_name }</small>
							<a href = "idear.jspx?_m=deleteComment&cid=${c.comment_id }&iid=${idear.i_id }"><i class="icon-trash"></i></a>
						</blockquote>
					</c:forEach>
					<div id = "list"></div>
				<a href = "idear.jspx?iid=${idear.i_id }">返回想法列表</a>
				
			</div>
		</div>
	</div>
	<script type="text/javascript">
		var xmlHttp;
		
		function createXMLHttp() {
			if(window.ActiveXObject) {
	    		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	    	} else {
	    		xmlHttp = new XMLHttpRequest();
	    	}
		}
	
  		document.getElementById("btn").onclick=function(){
  			createXMLHttp();
  			
  			var v = document.getElementById("iid").value;
  			var content = document.getElementById("dec").value;
  			document.getElementById("dec").value = "";
  			if(v.trim() != "") {
	  			xmlHttp.open("post", "idear.jspx", true);
	  			xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	  			xmlHttp.onreadystatechange = callback;
	  			xmlHttp.send("_m="+"comment"+"&iid="+v+"&content="+content);
  			}
  			
  		};
  		
  		function callback(){
			if(xmlHttp.readyState == 4) {
				if(xmlHttp.status == 200) {
				//接受返回的json数据
					var obj = JSON.parse(xmlHttp.responseText);
				
						//alert(obj.comment_id);
						var block = document.createElement("blockquote");
						var h4 = document.createElement("h4");
						var small = document.createElement("small");
						var a = document.createElement("a");
						var i = document.createElement("i");
						
						var h4content = document.createTextNode(obj.comment_content);
						var smallcontent = document.createTextNode(obj.member_name+"发布于"+obj.comment_createTime);
						a.setAttribute("href","idear.jspx?_m=deleteComment&cid=obj.comment_id&iid=${idear.i_id }");
						i.setAttribute("class","icon-trash");
						
						a.appendChild(i);
						h4.appendChild(h4content);
						small.appendChild(smallcontent);
						block.appendChild(h4);
						block.appendChild(small);
						block.appendChild(a);
						document.getElementById("list").appendChild(block);
						
					}
					
				}
			}
  		
	</script>
</body>
</html>